<?php
/**
 * Photoassociation
 *
 * Description de la classe
 *
 * @author Mathieu
 */
class PhotoAssociation extends Object {
    protected $id;
    protected $association_id;
    protected $nom;
    protected $lien;
    protected $added;

    protected $user;

    function __construct($id="", $params=array()) {
        if($id!='') {
            $this->id = $id;
            foreach($params as $key => $p) {
                $this->$key = $p;
            }
        }
    }

    function __toString() {
        return $this->nom;
    }

    public function load() {
        $db = Database::getInstance();
        $result = $db->query("SELECT * FROM photos_associations WHERE id = '".$this->id."'");
        if(sizeof($result) > 0) {
            foreach($result[0] as $key => $p) {
                $this->$key = $p;
            }
            return;
        }
        if(DEBUG) echo("Objet inconnu");
        return false;
    }
    public function getThumb() {
        if(!isset($this->association_id)||!isset($this->lien)) $this->load();
        return IMG_PATH.'association/'.$this->association_id.'/micro_'.$this->lien;
    }
}
?>
